#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define N 100

int a[N];

void gen_random(int value)
{
  srand(time(NULL));
  int i;

  for (i = 0; i != N; ++i)
  {
    a[i] = rand() % value;
  }
}

void how_many(int hist[])
{
  int i;
  for (i = 0; i != N; ++i)
  {
    ++hist[a[i]];
  }
}

void print_hist(int hist[], int value)
{
  int i;
  for (i = 0; i != value; ++i)
    printf("%d\t", i);
  printf("\n");

  int key = 1;
  while (key)
  {
    key = 0;
    for (i = 0; i != value; ++i)
    {
      if (hist[i])
      {
        printf("*\t");
        key = 1;
        --hist[i];
      }
      else
      {
        printf(" \t");
      }
    }
    printf("\n");
  }
}

int main()
{
  int histogram[10] = {0};

  gen_random(10);
  how_many(histogram);
  print_hist(histogram, 10);

}

